package com.jz.netthings.bloodsources.controller;


import com.jz.netthings.bloodsources.bean.XyVolunteeDetailInfo;
import com.jz.netthings.bloodsources.service.XyVolunteeService;
import com.jz.netthings.exception.AdscmSystemException;
import com.jz.netthings.support.SimpleCoreResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 义工管理 前端控制器
 * </p>
 *
 * @author 张凡
 * @since 2019-08-03
 */
@RestController
@RequestMapping("/adscm/bloodSources/xyVoluntee")
public class XyVolunteeController {
    @Autowired
    XyVolunteeService xyVolunteeService;
    @RequestMapping("/queryByCondition")
    public SimpleCoreResponse queryByCondition() throws AdscmSystemException {
        return new SimpleCoreResponse("200","查询成功", xyVolunteeService.queryByCondition());
    }
    @RequestMapping("/queryVolunteeDetailInfo")
    public SimpleCoreResponse queryVolunteeDetailInfo(String useNurseId) throws AdscmSystemException {
        List<XyVolunteeDetailInfo> returnData =  new ArrayList<>();
        //每次查询初始化实体类里面工具记录静态变量;
        XyVolunteeDetailInfo.initClearnStaticConst();
        returnData =  xyVolunteeService.queryVolunteeDetailInfo(useNurseId);
        //进行前端表格展示合计模块数据加工
        if(returnData!=null && returnData.size()>=1){
            XyVolunteeDetailInfo.isSum = true;
            XyVolunteeDetailInfo sumXyVolunteeDetailInfo =    new XyVolunteeDetailInfo();
            sumXyVolunteeDetailInfo.setUseVolunteeName("合计("+sumXyVolunteeDetailInfo.getSumvTotal()+")");
            sumXyVolunteeDetailInfo.setLinkProviderName(sumXyVolunteeDetailInfo.getSumpTotal()+"");
            sumXyVolunteeDetailInfo.setRound1((XyVolunteeDetailInfo.n1=XyVolunteeDetailInfo.n1==null?0:XyVolunteeDetailInfo.n1)+"");
            sumXyVolunteeDetailInfo.setRound2((XyVolunteeDetailInfo.n2=XyVolunteeDetailInfo.n2==null?0:XyVolunteeDetailInfo.n2)+"");
            sumXyVolunteeDetailInfo.setRound3((XyVolunteeDetailInfo.n3=XyVolunteeDetailInfo.n3==null?0:XyVolunteeDetailInfo.n3)+"");
            sumXyVolunteeDetailInfo.setRound4((XyVolunteeDetailInfo.n4=XyVolunteeDetailInfo.n4==null?0:XyVolunteeDetailInfo.n4)+"");
            sumXyVolunteeDetailInfo.setRound5((XyVolunteeDetailInfo.n5=XyVolunteeDetailInfo.n5==null?0:XyVolunteeDetailInfo.n5)+"");
            sumXyVolunteeDetailInfo.setRound6((XyVolunteeDetailInfo.n6=XyVolunteeDetailInfo.n6==null?0:XyVolunteeDetailInfo.n6)+"");
            sumXyVolunteeDetailInfo.setRound7((XyVolunteeDetailInfo.n7=XyVolunteeDetailInfo.n7==null?0:XyVolunteeDetailInfo.n7)+"");
            sumXyVolunteeDetailInfo.setRound8((XyVolunteeDetailInfo.n8=XyVolunteeDetailInfo.n8==null?0:XyVolunteeDetailInfo.n8)+"");
            sumXyVolunteeDetailInfo.setRound9((XyVolunteeDetailInfo.n9=XyVolunteeDetailInfo.n9==null?0:XyVolunteeDetailInfo.n9)+"");
            sumXyVolunteeDetailInfo.setRound10((XyVolunteeDetailInfo.n10=XyVolunteeDetailInfo.n10==null?0:XyVolunteeDetailInfo.n10)+"");
            sumXyVolunteeDetailInfo.setRound11((XyVolunteeDetailInfo.n11=XyVolunteeDetailInfo.n11==null?0:XyVolunteeDetailInfo.n11)+"");
            sumXyVolunteeDetailInfo.setRound12((XyVolunteeDetailInfo.n12=XyVolunteeDetailInfo.n12==null?0:XyVolunteeDetailInfo.n12)+"");
            sumXyVolunteeDetailInfo.setRound13((XyVolunteeDetailInfo.n13=XyVolunteeDetailInfo.n13==null?0:XyVolunteeDetailInfo.n13)+"");
            sumXyVolunteeDetailInfo.setRound14((XyVolunteeDetailInfo.n14=XyVolunteeDetailInfo.n14==null?0:XyVolunteeDetailInfo.n14)+"");
            sumXyVolunteeDetailInfo.setRound15((XyVolunteeDetailInfo.n15=XyVolunteeDetailInfo.n15==null?0:XyVolunteeDetailInfo.n15)+"");
            sumXyVolunteeDetailInfo.setRound16((XyVolunteeDetailInfo.n16=XyVolunteeDetailInfo.n16==null?0:XyVolunteeDetailInfo.n16)+"");
            sumXyVolunteeDetailInfo.setRound17((XyVolunteeDetailInfo.n17=XyVolunteeDetailInfo.n17==null?0:XyVolunteeDetailInfo.n17)+"");
            sumXyVolunteeDetailInfo.setRound18((XyVolunteeDetailInfo.n18=XyVolunteeDetailInfo.n18==null?0:XyVolunteeDetailInfo.n18)+"");
            sumXyVolunteeDetailInfo.setRound20((XyVolunteeDetailInfo.n20=XyVolunteeDetailInfo.n20==null?0:XyVolunteeDetailInfo.n20)+"");
            sumXyVolunteeDetailInfo.setRound21((XyVolunteeDetailInfo.n21=XyVolunteeDetailInfo.n21==null?0:XyVolunteeDetailInfo.n21)+"");
            sumXyVolunteeDetailInfo.setRound22((XyVolunteeDetailInfo.n22=XyVolunteeDetailInfo.n22==null?0:XyVolunteeDetailInfo.n22)+"");
            sumXyVolunteeDetailInfo.setRound23((XyVolunteeDetailInfo.n23=XyVolunteeDetailInfo.n23==null?0:XyVolunteeDetailInfo.n23)+"");
            sumXyVolunteeDetailInfo.setRound24((XyVolunteeDetailInfo.n24=XyVolunteeDetailInfo.n24==null?0:XyVolunteeDetailInfo.n24)+"");
            sumXyVolunteeDetailInfo.setRound25((XyVolunteeDetailInfo.n25=XyVolunteeDetailInfo.n25==null?0:XyVolunteeDetailInfo.n25)+"");
            sumXyVolunteeDetailInfo.setRound26((XyVolunteeDetailInfo.n26=XyVolunteeDetailInfo.n26==null?0:XyVolunteeDetailInfo.n26)+"");
            sumXyVolunteeDetailInfo.setRound19((XyVolunteeDetailInfo.n19=XyVolunteeDetailInfo.n19==null?0:XyVolunteeDetailInfo.n19)+"");
            sumXyVolunteeDetailInfo.setTotal(sumXyVolunteeDetailInfo.getUpTotal()+"");
            returnData.add(0,sumXyVolunteeDetailInfo);
        }
        return new SimpleCoreResponse("200","查询成功",returnData);
    }
}

